﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FUSE
{
    class Matrix
    {
        public int height;
        public int width;
        private int[,] values; 


        public Matrix(int width, int height)
        {
            this.height = height;
            this.width = width;
            values = new int[this.width, this.height];

        }

        public bool addValue(int width, int height, int value)
        {
            bool success = false;

            if (height == this.height && width == this.width)
            {
                values[width, height] = value;

                success = true;
            }

            return success;
        }

        public int getValue(int width, int height)
        {
            return values[width, height];
        }

        public void setValue(int width, int height, int value)
        {
            values[width, height] = value;           

        }

        public void initializeToZero()
        {
            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    values[x, y] = 0;
                }
            }
        }


        public int findValue(int value)
        {
            int retVal = -999999999;

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    if (values[width, height] == value)
                    {
                        retVal = values[width, height];
                    }
                }
            }

            return retVal;
        }

        public bool compare(Matrix b)
        {
            bool isSame = true;

            for (int x = 0; x < width; x++ )
            {
                for (int y = 0; y < height; y++)
                {
                    if (this.values[width, height] != b.values[width, height])
                    {
                        isSame = false;
                        x = width;
                        y = height;
                    }
                }
            }
            return isSame;
        }
    }
}
